<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>时间</title>
</head>
<body>

  <script>
    /* 实验: 将标签页隐藏后， setInterval和请求动画帧方法的运行状态 */
    let [a,b] = [0,0];

    setInterval(function() {
      a++;
    }, 100);

    !(function render() {
      b++;
      requestAnimationFrame(render);
    })();

    // 监听标签的可见性
    // document.visibilityState === 'visible'

    window.addEventListener('visibilitychange', function () {
      console.log(document.visibilityState);
      console.log('a', a);
      console.log('b', b);
      console.log('---------------');
    })

  </script>
  
</body>
</html>